#include<bits/stdc++.h>
using namespace std;
const int N=210;
int f[N][N];
int g[N][N];
int sum[N];
int a[N];
int n=0;
int main()
{
	cin>>n;
	int m=n+n;
	memset(g,0x3f,sizeof g);
	//memset(f,-0x3f,sizeof f);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i+n]=a[i];
		
	}
	//注意有的是遍历到n，有的是遍历到m 
	for(int i=1;i<=m;i++)
	{
		sum[i]=sum[i-1]+a[i];
		f[i][i]=g[i][i]=0;
	}
	for(int len=1;len<=n;len++)
	{
		for(int i=1;i+len-1<=m;i++)
		{
			int j=i+len-1;
			int s=sum[j]-sum[i-1];
			
			for(int k=i;k<j;k++)
			{
				f[i][j]=max(f[i][j],f[i][k]+f[k+1][j]+s);
				g[i][j]=min(g[i][j],g[i][k]+g[k+1][j]+s);
			}
		 } 
	}
	int ret1=-0x3f3f3f3f;
	int ret2=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
	{
		ret1=max(ret1,f[i][i+n-1]);
		ret2=min(ret2,g[i][i+n-1]);
	}
	cout<<ret2<<endl;
	cout<<ret1<<endl;
	return 0;
}